﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace HospitalSystem
{
    public partial class ReportScreening : System.Web.UI.Page
    {
        DataClasses1DataContext db = new DataClasses1DataContext();
        SqlConnection scon = new SqlConnection(@"Data Source=G1SN-PC\SQLEXPRESS;Initial Catalog=db27082555;Integrated Security=True");
        List<string> y = new List<string>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
                DataTable dt = new DataTable();
                string CID = (String)Session["CID"];
                //dt.Columns.Add("CaseNumber");
                //dt.Columns.Add("TextField");
                scon.Open();
                SqlCommand cmd = new SqlCommand("select Evaluation.CaseNo,Evaluation.EvalDateTime from person inner join Evaluation on Person.CID = Evaluation.CID where Person.cid = @ParamCID", scon);
                cmd.Parameters.AddWithValue("@ParamCID", CID);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read() != false)
                {
                    y.Add(reader["CaseNo"].ToString());
                }

                for (int i = 0; i < y.Count(); i++)
                {
                    DropDownList1.Items.Add(y[i]);
                }
                
            }
        }

        private List<Activity> GetEvaluationScrerning()
        {
            return (from a in db.Activities
                    join b in db.Services on a.SVCCode equals b.SVCCode
                    where b.SVCDEC.Equals("การประเมินคัดกรอง")
                    select a).ToList();
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            CheckBoxList1.DataSource = GetEvaluationScrerning();
            CheckBoxList1.DataTextField = "ACTDesc";
            CheckBoxList1.DataValueField = "ACTCode";
            CheckBoxList1.DataBind();
        }
    }
}